<template>
  <section class="index-wrap" style="margin-bottom: 200px; text-align: left;">
    <Form ref="index" :model="index" :label-width="150">
      <FormItem label="公司介绍：" prop="school_content">
        <i-input v-model="index.school_content" type="textarea" :rows="4"  placeholder="请输入..."></i-input>
      </FormItem>
      <FormItem label="LOGO">
        <upload-images @completeUpload="completeUpload4Logo"/>
        <div v-if="upload4Logo" class="preview-img">
          <img :src="upload4Logo.url" alt="img">
        </div>
      </FormItem>
      <FormItem label="公司图片" prop="school_content_img">
        <upload-images @completeUpload="completeUpload4School"/>
        <div v-if="upload4School" class="preview-img">
          <img :src="upload4School.url" alt="img">
        </div>
      </FormItem>
      <FormItem label="学校列表">
        <ul class="school-edu-list">
          <li v-for="(s, index) in schools" :key="'school'+index"><Input v-model="schools[index]" placeholder="学校名称" style="width: 300px" /><Icon type="ios-add-circle-outline" @click="addSchool" /><Icon type="ios-remove-circle-outline" @click="removeSchool(index)" /></li>
        </ul>
      </FormItem>
      <FormItem label="学历列表" >
        <ul class="school-edu-list">
          <li v-for="(e, index) in educations" :key="'edu'+index"><Input v-model="educations[index]" placeholder="学历名称" style="width: 300px" /><Icon type="ios-add-circle-outline" @click="addEducation" /><Icon type="ios-remove-circle-outline" @click="removeEducation(index)" /></li>
        </ul>
      </FormItem>
      <FormItem label="头部Banner" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in banners" :key="'banner'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl == 1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList1' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4Banner($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-if="upload4Banner[index]" :src="upload4Banner[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeBanner(index)" />
          </li>
          <li class="add-img img-li" @click="addBanner">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="Banner下方图片" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in crEducations" :key="'imgModel1'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl==1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList10' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4CrEdu($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-if="upload4CrEdu[index]" :src="upload4CrEdu[index]" alt="img">
            </div>
          </li>
        </ul>
      </FormItem>

      <FormItem label="咨询报名学习正面图" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in consultations" :key="'consultations'+index" class="img-li">
            <!--<Input v-model="item.imgDetail" placeholder="图片链接" class="img-select" />-->
            <!--<Select v-model="item.imgDetail" class="img-select">-->
            <!--<Option v-for="article in articleList" :value="''+article.id" :key="'articleList5' +article.id">{{ article.title }}</Option>-->
            <!--</Select>-->
            <upload-images @completeUpload="completeUpload4Consultation($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4Consultation[index]" :src="upload4Consultation[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeConsultation(index)" />
          </li>
          <li class="add-img img-li" @click="addConsultation">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="咨询报名学习背面图" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in consultations1" :key="'consultations1'+index" class="img-li">
            <!--<Input v-model="item.imgDetail" placeholder="图片链接" class="img-select" />-->

            <upload-images @completeUpload="completeUpload4Consultation1($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4Consultation1[index]" :src="upload4Consultation1[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeConsultation1(index)" />
          </li>
          <li class="add-img img-li" @click="addConsultation1">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="服务项目正面图" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in serviceItems" :key="'serviceItems'+index" class="img-li">
            <!--<Input v-model="item.imgDetail" placeholder="图片链接" class="img-select" />-->
            <Select v-model="item.imgDetail" class="img-select">
            <Option v-for="article in articleList" :value="''+article.id" :key="'articleList6' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4ServiceItems($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4ServiceItems[index]" :src="upload4ServiceItems[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeServiceItems(index)" />
          </li>
          <li class="add-img img-li" @click="addServiceItems">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="服务项目背面图" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in serviceItems1" :key="'serviceItems1'+index" class="img-li">
            <Select v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList7' +article.id">{{ article.title }}</Option>
            </Select>

            <upload-images @completeUpload="completeUpload4ServiceItems1($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4ServiceItems1[index]" :src="upload4ServiceItems1[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeServiceItems1(index)" />
          </li>
          <li class="add-img img-li" @click="addServiceItems1">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="通知文章" prop="notice_article">
        <Select v-model="noticeArticles" multiple>
          <Option v-for="article in articleList" :value="''+article.id" :key="'articleList' +article.id">{{ article.title }}</Option>
        </Select>
      </FormItem>
      <FormItem label="通知文章分类" prop="notice_category">
        <ul>
            <Select
              v-model="index.notice_category"
              :loading="loading1">
              <Option v-for="ca in categoryList" :value="''+ca.id" :key="'categoryList'+ca.id">{{ca.name}}</Option>
            </Select>
        </ul>
      </FormItem>

      <FormItem label="底部Banner1" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in imgModels1" :key="'imgModel1'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl==1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList3' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4ImgModel1($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-if="upload4ImgModel1[index]" :src="upload4ImgModel1[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeImgModel1(index)" />
          </li>
          <li class="add-img img-li" @click="addImgModel1">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="底部Banner1-小图片" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in xtpModel1" :key="'xtpModel1'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl == 1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList8' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4XtpModel1($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-if="upload4XtpModel1[index]" :src="upload4XtpModel1[index]" alt="img">
            </div>
            <!--<Icon type="md-close" class="remove-img" @click="removeXtpModel1(index)" />-->
          </li>
          <!--<li class="add-img img-li" @click="addXtpModel1">-->
            <!--<Icon type="ios-add-circle-outline" />-->
          <!--</li>-->
        </ul>
      </FormItem>

      <FormItem label="底部Banner2" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in imgModels2" :key="'imgModel2'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl == 1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList2' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4ImgModel2($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4ImgModel2[index]" :src="upload4ImgModel2[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeImgModel2(index)" />
          </li>
          <li class="add-img img-li" @click="addImgModel2">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="底部Banner2-小图片" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in xtpModel2" :key="'xtpModel2'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl == 1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList9' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4XtpModel2($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-if="upload4XtpModel2[index]" :src="upload4XtpModel2[index]" alt="img">
            </div>
            <!--<Icon type="md-close" class="remove-img" @click="removeXtpModel1(index)" />-->
          </li>
          <!--<li class="add-img img-li" @click="addXtpModel1">-->
          <!--<Icon type="ios-add-circle-outline" />-->
          <!--</li>-->
        </ul>
      </FormItem>

      <FormItem label="文章页Banner" >
        <ul class="img-add-del-list">
          <li v-for="(item,index) in banners1" :key="'banners1'+index" class="img-li">
            <Checkbox v-model="item.isUrl" true-value="1" false-value="0">自定义链接</Checkbox>
            <Input v-show="item.isUrl == 1" v-model="item.imgDetail" placeholder="请输入链接" class="img-select" />
            <Select v-show="item.isUrl != 1" v-model="item.imgDetail" class="img-select">
              <Option v-for="article in articleList" :value="''+article.id" :key="'articleList10' +article.id">{{ article.title }}</Option>
            </Select>
            <upload-images @completeUpload="completeUpload4Banner1($event,index)" class="img-upload" style="display: inline-block"/>
            <div class="img-add-del-panel">
              <img v-show="upload4Banner1[index]" :src="upload4Banner1[index]" alt="img">
            </div>
            <Icon type="md-close" class="remove-img" @click="removeBanner1(index)" />
          </li>
          <li class="add-img img-li" @click="addBanner1">
            <Icon type="ios-add-circle-outline" />
          </li>
        </ul>
      </FormItem>

      <FormItem label="报考倒计时" prop="introduce">
        <Date-picker type="date" v-model="index.end_date" placeholder="选择日期" style="width: 200px"></Date-picker>
      </FormItem>

      <FormItem>
        <Button @click="handleReset('index')">重置</Button>
        <Button type="primary" style="margin-left: 8px" @click="handleSubmit('index')">更新</Button>
      </FormItem>
    </Form>
  </section>
</template>

<script>
  import {mapState, mapActions} from 'vuex';
  import UploadImages from '../../components/UploadImages'
  import mavonEditerUpload from '../../components/mavonEditerUpload'

  export default {
    components: {
      UploadImages,
      mavonEditerUpload
    },
    data() {
      return {
        index:{},
        upload4School: null,
        upload4Logo: null,
        noticeArticles:[],
        articleList:[],
        noticeCategorys:[],
        categoryList: [],
        banners: [{}],
        upload4Banner:{},
        schools:[],
        educations:[],

        banners1: [{}],
        upload4Banner1:{},

        crEducations: [{}],
        upload4CrEdu:{},

        consultations: [{}],
        upload4Consultation:{},

        consultations1: [{}],
        upload4Consultation1:{},

        serviceItems: [{}],
        upload4ServiceItems:{},

        serviceItems1: [{}],
        upload4ServiceItems1:{},

        imgModels1: [{}],
        upload4ImgModel1:{},

        imgModels2: [{}],
        upload4ImgModel2:{},

        xtpModel1: [{}],
        upload4XtpModel1:{},

        xtpModel2: [{}],
        upload4XtpModel2:{},

        loading1:false,
        loading:true,
      }
    },
    computed: {
      ...mapState({
        uploadTokenData: state => state.uploadToken.uploadTokenData,
      })
    },
    created() {
      this.init()
    },

    methods: {
      ...mapActions({
        updateIndex: 'index/updateIndex',
        getIndexDetail: 'index/indexDetail',
        getCategoryList: 'category/getCategoryList',
        getArticleList: 'article/articleList',
      }),

      async init(){
        this.index = await this.getIndexDetail()

        if(this.index.school_content_img){
          this.upload4School = {}
          this.upload4School.url = this.index.school_content_img
        }
        if(this.index.logo){
          this.upload4Logo = {}
          this.upload4Logo.url = this.index.logo
        }
        if(this.index.notice_article){
          this.noticeArticles = this.index.notice_article.split('|')
        }
        // if(this.index.notice_category){
        //   this.noticeCategorys = this.index.notice_category.split('|')
        // }
        if(this.index.banner){
          this.banners = this.checkImgLink(this.index.banner.split('|'))

          this.banners.forEach((item, index) => {
            this.upload4Banner[index] = item.img
          })
        }

        if(this.index.banner1){
          this.banners1 = this.checkImgLink(this.index.banner1.split('|'))

          this.banners1.forEach((item, index) => {
            this.upload4Banner1[index] = item.img
          })
        }

        if(this.index.schools){
          this.schools = this.index.schools.split('|')
        }

        if(this.index.educations){
          this.educations = this.index.educations.split('|')
        }

        if(this.index.img_model1){
          this.imgModels1 = this.checkImgLink(this.index.img_model1.split('|'))

          this.imgModels1.forEach((item, index) => {
            this.upload4ImgModel1[index] = item.img
          })
        }

        if(this.index.cr_education){
          this.crEducations = this.checkImgLink(this.index.cr_education.split('|'))

          this.crEducations.forEach((item, index) => {
            this.upload4CrEdu[index] = item.img
          })
        }

        if(this.index.img_model2){
          this.imgModels2 = this.checkImgLink(this.index.img_model2.split('|'))

          this.imgModels2.forEach((item, index) => {
            this.upload4ImgModel2[index] = item.img
          })
        }

        if(this.index.xtp_model1){
          this.xtpModel1 = this.checkImgLink(this.index.xtp_model1.split('|'))

          this.xtpModel1.forEach((item, index) => {
            this.upload4XtpModel1[index] = item.img
          })
        }

        if(this.index.xtp_model2){
          this.xtpModel2 = this.checkImgLink(this.index.xtp_model2.split('|'))

          this.xtpModel2.forEach((item, index) => {
            this.upload4XtpModel2[index] = item.img
          })
        }

        if(this.index.consultation){
          this.consultations = this.checkImgLink(this.index.consultation.split('|'))

          this.consultations.forEach((item, index) => {
            this.upload4Consultation[index] = item.img
          })
        }

        if(this.index.consultation_b){
          this.consultations1 = this.checkImgLink(this.index.consultation_b.split('|'))

          this.consultations1.forEach((item, index) => {
            this.upload4Consultation1[index] = item.img
          })
        }

        if(this.index.service_items){
          this.serviceItems = this.checkImgLink(this.index.service_items.split('|'))

          this.serviceItems.forEach((item, index) => {
            this.upload4ServiceItems[index] = item.img
          })
        }

        if(this.index.service_items_b){
          this.serviceItems1 = this.checkImgLink(this.index.service_items_b.split('|'))

          this.serviceItems1.forEach((item, index) => {
            this.upload4ServiceItems1[index] = item.img
          })
        }

        const ret = await this.getArticleList({
          include: 'is_del',
          page:1,
          pageSize: 1000
        });
        this.articleList = ret.data;

        this.categoryList = await this.getCategoryList({parent_id:0});
      },

      checkImgLink(list){
        return list.map(item => {
          let itemInfo = item.split('@')
          return {img: itemInfo[0], imgDetail: itemInfo[1], isUrl: itemInfo[2]}
        })
      },

      addSchool(){
        this.schools.push('')
      },

      removeSchool(index){
        this.schools.splice(index,1)
      },

      addEducation(){
        this.educations.push('')
      },

      removeEducation(index){
        this.educations.splice(index,1)
      },

      addBanner(){
        let imgObj = {'img':'', 'imgDetail':'',isUrl:0}
        this.banners.push(imgObj);
        this.upload4Banner[this.banners.length - 1] = imgObj.img
      },

      removeBanner(index){
        this.banners.splice(index,1)
        this.upload4Banner[index] = null
      },

      addBanner1(){
        let imgObj = {'img':'', 'imgDetail':'',isUrl:0}
        this.banners1.push(imgObj);
        this.upload4Banner1[this.banners1.length - 1] = imgObj.img
      },

      removeBanner1(index){
        this.banners1.splice(index,1)
        this.upload4Banner1[index] = null
      },

      addImgModel1(){
        let imgObj = {'img':'', 'imgDetail':'',isUrl:0}
        this.imgModels1.push(imgObj);
        this.upload4ImgModel1[this.imgModels1.length - 1] = imgObj.img
      },

      removeImgModel1(index){
        this.imgModels1.splice(index,1)
        this.upload4ImgModel1[index] = null
      },

      addImgModel2(){
        let imgObj = {'img':'', 'imgDetail':'',isUrl:0}
        this.imgModels2.push(imgObj);
        this.upload4ImgModel2[this.imgModels2.length - 1] = imgObj.img
      },

      removeImgModel2(index){
        this.imgModels2.splice(index,1)
        this.upload4ImgModel2[index] = null
      },

      addConsultation(){
        let imgObj = {'img':'', 'imgDetail':''}
        this.consultations.push(imgObj);
        this.upload4Consultation[this.consultations.length - 1] = imgObj.img
      },

      removeConsultation(index){
        this.consultations.splice(index,1)
        this.upload4Consultation[index] = null
      },

      addConsultation1(){
        let imgObj = {'img':'', 'imgDetail':''}
        this.consultations1.push(imgObj);
        this.upload4Consultation1[this.consultations1.length - 1] = imgObj.img
      },

      removeConsultation1(index){
        this.consultations1.splice(index,1)
        this.upload4Consultation1[index] = null
      },

      addServiceItems(){
        let imgObj = {'img':'', 'imgDetail':''}
        this.serviceItems.push(imgObj);
        this.upload4ServiceItems[this.serviceItems.length - 1] = imgObj.img
      },

      removeServiceItems(index){
        this.serviceItems.splice(index,1)
        this.upload4ServiceItems[index] = null
      },

      addServiceItems1(){
        let imgObj = {'img':'', 'imgDetail':''}
        this.serviceItems1.push(imgObj);
        this.upload4ServiceItems1[this.serviceItems1.length - 1] = imgObj.img
      },

      removeServiceItems1(index){
        this.serviceItems1.splice(index,1)
        this.upload4ServiceItems1[index] = null
      },

      remoteMethod4Category(query){

      },

      // 上传图片成功回调
      completeUpload4School(data) {
        this.upload4School = data;
        this.index.school_content_img = data.url;
      },

      completeUpload4Logo(data) {
        this.upload4Logo = data;
        this.index.logo = data.url;
      },

      // 上传图片成功回调
      completeUpload4Banner(data,index) {
        this.upload4Banner[index] = data.url;
        this.upload4Banner = Object.assign({}, this.upload4Banner)
        this.banners[index].img = data.url
      },

      completeUpload4Banner1(data,index) {
        this.upload4Banner1[index] = data.url;
        this.upload4Banner1 = Object.assign({}, this.upload4Banner1)
        this.banners1[index].img = data.url
      },

      completeUpload4Consultation(data,index) {
        this.upload4Consultation[index] = data.url;
        this.upload4Consultation = Object.assign({}, this.upload4Consultation)
        this.consultations[index].img = data.url
      },

      completeUpload4Consultation1(data,index) {
        this.upload4Consultation1[index] = data.url;
        this.upload4Consultation1 = Object.assign({}, this.upload4Consultation1)
        this.consultations1[index].img = data.url
      },

      completeUpload4ServiceItems(data,index) {
        this.upload4ServiceItems[index] = data.url;
        this.upload4ServiceItems = Object.assign({}, this.upload4ServiceItems)
        this.serviceItems[index].img = data.url
      },

      completeUpload4ServiceItems1(data,index) {
        this.upload4ServiceItems1[index] = data.url;
        this.upload4ServiceItems1 = Object.assign({}, this.upload4ServiceItems1)
        this.serviceItems1[index].img = data.url
      },

      completeUpload4CrEdu (data,index) {
        this.upload4CrEdu[index] = data.url;
        this.upload4CrEdu = Object.assign({}, this.upload4CrEdu)
        this.crEducations[index].img = data.url
      },

      completeUpload4ImgModel1 (data,index) {
        this.upload4ImgModel1[index] = data.url;
        this.upload4ImgModel1 = Object.assign({}, this.upload4ImgModel1)
        this.imgModels1[index].img = data.url
      },

      completeUpload4ImgModel2 (data,index) {
        this.upload4ImgModel2[index] = data.url;
        this.upload4ImgModel2 = Object.assign({}, this.upload4ImgModel2)
        this.imgModels2[index].img = data.url
      },

      completeUpload4XtpModel1 (data,index) {
        this.upload4XtpModel1[index] = data.url;
        this.upload4XtpModel1 = Object.assign({}, this.upload4XtpModel1)
        this.xtpModel1[index].img = data.url
      },

      completeUpload4XtpModel2 (data,index) {
        this.upload4XtpModel2[index] = data.url;
        this.upload4XtpModel2 = Object.assign({}, this.upload4XtpModel2)
        this.xtpModel2[index].img = data.url
      },

      async handleSubmit(){
        try {
          if(this.noticeArticles.length){
            this.index.notice_article = this.noticeArticles.join('|')
          }

          if(this.schools.length){
            this.index.schools = this.schools.join('|')
          }

          if(this.educations.length){
            this.index.educations = this.educations.join('|')
          }

          if(this.banners.length){
            let preList = this.banners.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.banner = preList.join('|')
          }

          if(this.banners1.length){
            let preList = this.banners1.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.banner1 = preList.join('|')
          }

          if(this.crEducations.length){
            let preList = this.crEducations.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.cr_education = preList.join('|')
          }

          if(this.imgModels1.length){
            let preList = this.imgModels1.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.img_model1 = preList.join('|')
          }

          if(this.imgModels2.length){
            let preList = this.imgModels2.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl  || ''
            })

            this.index.img_model2 = preList.join('|')
          }

          if(this.xtpModel1.length){
            let preList = this.xtpModel1.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.xtp_model1 = preList.join('|')
          }

          if(this.xtpModel2.length){
            let preList = this.xtpModel2.map(item => {
              return item.img + '@' + (item.imgDetail || '') + '@' + item.isUrl || ''
            })

            this.index.xtp_model2 = preList.join('|')
          }

          if(this.consultations.length){
            let preList = this.consultations.map(item => {
              return item.img + '@' + item.imgDetail || ''
            })

            this.index.consultation = preList.join('|')
          }

          if(this.consultations1.length){
            let preList = this.consultations1.map(item => {
              return item.img + '@' + item.imgDetail || ''
            })

            this.index.consultation_b = preList.join('|')
          }

          if(this.serviceItems.length){
            let preList = this.serviceItems.map(item => {
              return item.img + '@' + item.imgDetail || ''
            })

            this.index.service_items = preList.join('|')
          }

          if(this.serviceItems1.length){
            let preList = this.serviceItems1.map(item => {
              return item.img + '@' + item.imgDetail || ''
            })

            this.index.service_items_b = preList.join('|')
          }

          await this.updateIndex(this.index);
          this.$Message.success('更新成功');
          // window.location.href = "/article/list";

        } catch (e) {
          this.$Message.error('更新失败')
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
  ul{
    list-style: none;
    margin: 0;
    padding: 0;
  }

  button.ivu-icon{
    color: #666;
  }

  .preview-img{
    margin-top: 10px;

    img{
      height: 100px;
    }
  }

  .school-edu-list{
    & li{
      margin-top: 10px;

      & i{
        font-size: 40px;
        cursor: pointer;
      }
    }
  }

  .img-add-del-list{
    overflow: hidden;
    zoom: 1;

    & .img-li{
      float: left;
      border: 1px solid #ccc;
      position: relative;
      width: 400px;
      margin-right: 20px;
      overflow: visible;

      & .img-select{
        width: 280px;
        float: left;
        box-sizing: border-box;
      }

      & .img-upload{
        width: 100px;
        float: right;
        box-sizing: border-box;
      }

      & .img-add-del-panel{
        margin-top: 20px;
        float: left;
        width: 100%;
        height: 200px;
        position: relative;
        text-align: center;

        & img{
          max-width: 100%;
          max-height: 100%;
        }
      }

      &.add-img{
        height: 100px;
        width: 100px;
        line-height: 100px;
        background: #f6f6f6;
        cursor: pointer;
        text-align: center;
        font-size: 50px;

        &:hover{
          background: #ddd;
        }
      }

      & .remove-img{
        position: absolute;
        bottom: 0px;
        right: 0px;
        z-index: 101;
        cursor: pointer;
        font-size: 30px;

        &:hover{
          color: red;
        }
      }
    }
  }
</style>
